package com.leff.cards.entity;

import com.google.appengine.api.datastore.Entity;
import com.leff.cards.Dictionary;
import com.leff.cards.StoreWrapper;

public class Invitation extends EntityWrapper {

	public static final String KIND = "Invitation";
	
	public static final String GROUP_ID = "group_id";
	public static final String USER_FB_ID = "user_fbid";
	
	public Invitation(Entity E) {
		super(E);
	}
	public Invitation(long groupId, long fbid) {
		super(KIND);
		
		setGroupId(groupId);
		setUserFbid(fbid);
	}
	
	public void setGroupId(long id) {
		put(GROUP_ID, id);
	}
	public long getGroupId() {
		return (Long)get(GROUP_ID);
	}
	
	public void setUserFbid(long fbid) {
		put(USER_FB_ID, fbid);
	}
	public Long getUserFbid() {
		return (Long)get(USER_FB_ID);
	}
	
	@Override
	public Dictionary toJSON() {
		
		Dictionary obj = new Dictionary();
		
		Group G = StoreWrapper.getGroupById(getGroupId());
		obj.put("group", G.toJSON());
		
		return obj;
	}
}
